
//JS
layui.use([ 'layer', 'table'], function() {
    var layer = layui.layer
        table = layui.table,
        $ = layui.$;


    <!-- 动态表格 -->
    table.render({
        elem: '#titleStudent-table',
        toolbar: '#titleStudentToolBar',
        page: true,
        height:700,
        url: '/getTitle',
        where: {queryKey: '', type: 1},
        cols:[
            [ //标题栏
                {field: 'xtId', title: '编号', width: 90, align: 'center', sort: true, fixed: 'left'},
                {field: 'title', title: '课题名称', align: 'center'},
                {field: 'collegeName', title: '学院',align: 'center'},
                {field: 'majorName', title: '专业',align: 'center'},
                {field: 'tno', title: '指导教师工号', width: 130, align: 'center'},
                {field: 'tName', title: '指导教师姓名', width: 120, align: 'center'},
                {field: 'no', title: '选题学生学号', width: 130, align: 'center'},
                {field: 'sname', title: '学生姓名', width: 110, align: 'center'},
                {field: 'addtime', title: '申请时间', width: 130, align: 'center'},
                {field: 'from', title: '课题来源', width: 120, align: 'center', hide: true},
                {field: 'categoty', title: '课题类别', width: 100, align: 'center', hide: true},
                {field: 'nature', title: '课题性质', width: 140, align: 'center', hide: true},
                {field: 'intr', title: '课题简介', width: 240, align: 'center', hide: true},
                {field: 'opinoin', title: '审核意见', align: 'center', width: 120, hide: true},
                {
                    field: 'state', title: '审核状态', width: 140, align: 'center', fixed: 'right', templet: function (res) {
                        if (res.state === '审核完成') {
                            return '<span style="color: green">审核完成</span>';
                        } else {
                            return '<span style="color: #1E9FFF">审核中</span>';
                        }
                    }
                },
                {
                    field: 'isPass', title: '是否通过', width: 140, align: 'center', fixed: 'right', templet: function (res) {
                        if (res.isPass === '不通过') {
                            return '<span style="color: red">不通过</span>';
                        } else if (res.isPass === '通过') {
                            return '<span style="color: green">通过</span>';
                        } else {
                            return '<span style="color: #1E9FFF">审核中</span>';
                        }
                    }
                },
                {title: '操作', width: 100, toolbar: '#titleStudentBtn', align: 'center', fixed: 'right'}
            ]
        ]
        , even: true
        , page: true
        , limits: [13, 26, 39]
        , limit: 13
        , text: {
            none: '<div class="layui-anim layui-anim-scaleSpring"  style="margin-top: 150px"><i class="layui-icon"  style="color: #009f95;font-size: 150px;border-bottom: #009f95 solid 2px;padding:15px;margin-top: 50px" >&#xe664;</i><br>' +
                '<br><br><br><br><div class="layui-text" style="font-size: 25px;margin-top: 25px;color: #009f95">好像没有没找到数据呢</div></div>'
            ,
            error: '<div style="margin-top: 150px"><i class="layui-icon"  style="color: #009f95;font-size: 150px;border-bottom: #009f95 solid 2px;padding:15px;margin-top: 50px" >&#xe664;</i><br>' +
                '<br><div class="layui-text" style="font-size: 25px;margin-top: 25px;color: #009f95">好像没有出错了呢</div></div>'
        }
    });
    //监听行工具事件
    table.on('tool(titleStudent-table)', function (obj) {
        let data = obj.data;
        if (obj.event === 'titleStu-query') {
            layer.open({
                title: '学生自主提交课题详情'
                , offset: 50
                , type: 1
                , area: ['740px', '550px']
                , content: $('#titleStudent-show-box')
                , success: function (layerObj) {
                    $(".layui-layer-shade").appendTo(layerObj.parent());
                    setTaskDetail(data);
                }
                , end: function () {
                    $('#titleStudent-show-box').css('display', 'none');
                }
            });
        }
    });
    layui.layer.closeAll('loading');

});

//设置详情
function setTaskDetail(data) {
    $("#task-intr").html(data.intr);
    $("#task-from").html(data.from);
    $("#task-category").html(data.categoty);
    $("#task-addtime").html(data.addtime);
    $("#task-nature").html(data.nature);
    $("#task-college").html(data.collegeName);
    $("#task-major").html(data.majorName);
    $("#task-tname").html(data.tName);
    $("#task-state").html(data.state);
    $("#task-sno").html(data.no);
    $("#task-id").html(data.xtId);
    $("#task-title").html(data.title);
    $("#task-tno").html(data.tno);
    $("#task-sname").html(data.sname);
    $("#task-opinion").html(data.opinoin);
}